Den Original™ Player Requirements System#78
Open
portfiend wants to merge 55 commits intoTheDenSS14:masterfrom
Open
Den Original™ Player Requirements System#78portfiend wants to merge 55 commits intoTheDenSS14:masterfrom
portfiend wants to merge 55 commits intoTheDenSS14:masterfrom
Conversation
realized it doesnt need to be removed from the list if it fails requirements because requirements are contextual
Contributor
Author
|
This PR is now ready for review. It's also a prerequisite for implementing loadouts and traits |
honeyed-lemons
approved these changes
Mar 28, 2026
Contributor
|
oh oops forgot to write a thing. The code is clean, well organized, and does its job. Comments seem to be in place everywhere they need to go, and play testing revealed everything works properly! |
Contributor
|
ill check it too later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
About the PR
This PR basically rewrites WizDen's
JobRequirementsto be cleaner and more flexible. "Requirement checking" logic has been decoupled from "reason string" logic, and it's much easier to add new requirement parameters and requirement types. The APIs for requirement checking are much more straightforward.This is drawing a lot from my prebase refactor work on CharacterRequirements.
Why / Balance
We used that requirement system A LOT, and my refactors to the prebase system made it pretty easy to add new requirements. In addition, this system should make it possible to run requirements through tests, as making all parameters of the requirements optional means that we can skip over irrelevant requirements.
This is needed for traits and loadouts etc.
Technical details
IPlayerRequirementis a new interface for defining a "player requirement".IPlayerRequirements all have the following fields and methods:bool Inverted: Whether or not this requirement should be inverted. Fails become passes and vice versa.bool MustPassPreCheck: If a context fails the pre-check, normally it would count as an auto-pass so that the requirement gets "ignored" in checks. If this is enabled, instead, requirements that fail pre-checking will auto-fail.bool HideIfFailed: Whether or not the item associated with the requirement should be hidden from the player's UI if this requirement fails.bool PreCheck(PlayerRequirementContext context): This method checks a context to make sure all required fields are non-null.bool CheckRequirement(PlayerRequirementContext context): Performs the actual requirement check.string? GetReason(): Produces a "reason string" for a requirement. Notice how this logic is now decoupled from requirement checking!There's also a new
IPlayerRangeRequirement<T>interface, which can be used to add requirements that are characterized by nullifiable "minimum" and "maximum" range values.CountRequirementis a data definition used for defining dynamic "count" fields for "overlapping list" requirements. For example,PlayerTraitRequirementhas aHashSet<ProtoId<EntityTraitPrototype>> Traitsdatafield and aCountRequirementfield, which allows you to define trait requirements as "at least 2 traits", "exactly 1", "all traits", et cetera.PlayerRequirementContextis a new record definition that stores "contextual data" on the player that is being checked, like their current playtimes or selected character. All fields are nullable; null fields are "optional" and ignored in checks (at least, depending onMustPassPreCheck).EntityTraits have requirements now! They're displayed in the UI. If you fail the requirements, they will not be applied to your character... however, keep in mind that admeme traits will ignore requirements!
JobPrototypeandAntagPrototypenow useIPlayerRequirements, and bothJobRequirementsManagerandPlayTimeTrackingSystemhave been refactored to use these. Old requirement functionality has been preserved, but these are deprecated and all new requirements should useIPlayerRequirements.The trait selector UI control has been updated to change visibility based on the
HideIfFailedvalue of its requirements, as well as supply a requirement "reason" description as part of its tooltip.Loadouts, antags, and job timer requirements have been migrated in YML to use the new player requirement system.
Playtesting Checklist
Sorry, this is a big ass PR. Here's the part that actually affects things in game
self traits:add MorphHumanOnishould still work.game.role_timerscvar is disabled.game.role_loadout_timerscvar is disabled.Media
Traits
Jobs
Antagonists
Loadouts
Requirements
Licensing
Breaking changes
YML-side
The
requirementsfield injobandantagprototypes has been deprecated. You should use theplayerRequirementsfield instead for all future requirements.IPlayerRequirements have different syntax fromJobRequirements, so you will need to find the corresponding player requirement to replace the old requirement.Here is an example of old
JobRequirementplaytime fields:Here are their corresponding replacement
IPlayerRequirements:In addition, loadouts have a new LoadoutEffect:
PlayerRequirementLoadoutEffect. This should be used in place ofJobRequirementLoadoutEffectin all future loadout requirements. For instance:The
requirementTypefield, in this case, is eitherRoleorLoadout, which determines which CVar gets used for toggling this playtime requirement on or off - the role timer cvar, or the loadout timer cvar.Changelog
🆑